#include <stdio.h>

#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

#define MAP_DOWN 21

#define MAP_LEFT 21

#define BLACK	'1'

#define WHITE	'2'
char map[MAP_DOWN][MAP_LEFT];


void init(){

	int i ;

	for( i = 0 ; i <=(MAP_DOWN-1) ; i++){

		map[0][i]='#';

	}

	for( i = 0 ; i <=(MAP_DOWN-1) ; i++){

		map[(MAP_DOWN-1)][i]='#';

	}

	

	for( i = 1 ; i <= (MAP_DOWN-2) ; i++ ){

		map[i][0]='#';

	}

	

	for( i = 1 ; i <= (MAP_DOWN-2) ; i++ ){

		map[i][(MAP_DOWN-1)]='#';

	}



	for( i = 1 ; i <= (MAP_DOWN-2) ; i++){

		int j ;

		for( j = 1 ; j <=(MAP_LEFT-2) ; j++){

			map[i][j]='*';

		}

	}

}



int between(int b1 ,int b2, int a){

	if(a<=b2&&a>=b1){

		return 1;

	}

	return 0;

}



int placeok(int row ,int colum){

	if(!between(1,(MAP_DOWN-1),row)||!between(1,(MAP_LEFT-1),colum)){

		return 0;

	}

	if(map[row][colum]!='*'){

		return 0;

	}

	return 1;

}



int PlaceGo(int row , int colum , char color ){

	if(!placeok(row,colum)){

		return 0;

	}

	if(color!=BLACK&&color!=WHITE){

		return 0;

	}

	map[row][colum]=color;

	return 1;

}



void testShow(){

	int i ;

	for(i = 0 ; i <= (MAP_DOWN-1) ; i++){

		int j ;

		for(j = 0; j <= (MAP_LEFT-1) ; j++){

			printf("%c ",map[i][j]);

		}

		printf("\n");

	}

}



void testinput(){

	int a , b;

	char c;

	while(scanf("%d,%d,%c",&a,&b,&c)){

		printf("\n");

		if(!PlaceGo(a,b,c)){

			printf("Error\n");

			continue;

		}

		testShow();

	}

}

void test(){

	init();

	testShow();

	testinput();

}

int sum_left(int row,int colum,char c){

	int sum = 0;

	int left = colum-1 ;

	while(map[row][left]==c){

		sum++;

		left--;

	}

	

	return sum;

}

int sum_right(int row ,int colum , char c ){

	int sum = 0 ;

	int right = colum + 1;

	while(map[row][right]==c){

		sum++;

		right++;

	}



	return sum;

}

int sum_up(int row , int colum , char c){

	int sum = 0 ;

	int up = row - 1;

	while(map[up][colum]==c){

		sum++;

		up--;

	}

	return sum;

}

int sum_down(int row , int colum , char c){

	int sum = 0 ;

	int down = row + 1;

	while(map[down][colum]==c){

		sum++;

		down++;

	}

	return sum;

}

int sum_left_up(int row , int colum , char c){

	int sum = 0 ;

	int up = row - 1;

	int left = colum - 1;

	while(map[up][left]==c){

		sum ++;

		up--;

		left--;

	} 

	return sum;

}

int sum_right_down(int row , int colum , char c){

	int sum = 0 ;

	int down = row + 1;

	int right = colum + 1;

	while(map[down][right]==c){

		sum ++;

		down++;

		right++;

	} 

	return sum;
}

int sum_right_up(int row , int colum , char c){

	int sum = 0 ;

	int right = colum + 1;

	int up = row  - 1 ;

	while(map[up][right]==c){

		sum++;

		right ++ ;

		up--;

	}
	return sum;

}

int sum_left_down(int row , int colum , char c){

	int sum = 0 ;

	int left = colum - 1;

	int down = row  + 1 ;

	while(map[down][left]==c){

		sum++;

		left -- ;

		down++;

	}
	return sum;

}

int judgewhite(int row,int colum){
	int left_right = 1 ;
	int up_down = 1 ;
	int leftup_rightdown = 1 ;
	int rightup_leftdown = 1 ;

	
	left_right = left_right + sum_left(row,colum,'2') + sum_right(row,colum,'2');
	if(left_right>=5){

		return 2 ;

	}
	
	up_down = up_down + sum_up(row,colum,'2')+ sum_down(row,colum,'2');
	if(up_down>=5){

		return 2 ;

	}

	leftup_rightdown = leftup_rightdown + sum_left_up(row, colum , '2') + sum_right_down(row,colum , '2');
	if(leftup_rightdown>=5){

		return 2;

	}

	rightup_leftdown = rightup_leftdown + sum_right_up(row,colum,'2') + sum_left_down(row,colum,'2');
	if(rightup_leftdown>=5){

		return 2;

	}

	return 0;

}


int forbid_three(int left_space , int left , int right_space , int right , char end1 , char end2){
    int result = 0 ;
    if(end1!='*'||end2!='*'){
        return result;
    }

    if(left_space==left){
        if(right_space==right){
            if(left+right+1==3){
                result++;
            }
        }else{
            if(left+right+1==3){
                result++;
            }
            if(left+right_space+1==3){
                result++;
            }
        }
    }else{
        if(right_space==right){
            if(left+right+1==3){
                result++;
            }
            if(left_space+right+1==3){
                result++;
            }
        }else{
            if(left+right+1==3){
                result++;
            }
            if(left+right_space+1==3){
                result++;
            }
            if(left_space+right+1==3){
                result++;
            }
            if(left_space+right_space+1==3){
                result++;
            }
        }
    }

    return result;
}

int forbid_four(int left_space , int left , int right_space , int right , char end1 , char end2){
    int result = 0 ;
    if(left+right+1==4){
        if(end1=='*'||end2=='*'){
            result++;
        }
    }

    if(right_space>right){
        if(left+right_space+1==4){
            result++;
        }
    }

    if(left_space>left){
        if(left_space+right+1==4){
            result++;
        }
        if(right_space>right){
            if(left_space+right_space+1==4){
                result++;
            }
        }
    }

    return result;
}


void forbid_rule_left_right2(int row,int colum,int* three , int* four){
    *three=0;
    *four=0;
    char end1 , end2;
    int leftskip = 1;
    int leftsum_space = 0;
    int leftsum = 0 ;
    int left = colum-1;
    int right = colum +1;

    while(1){

            if(map[row][left]=='1'){

                if(leftskip==1){
                    leftsum++;
                }

                leftsum_space++;

                left--;

            }else if(map[row][left]=='*'){

                    if(map[row][left-1]!='1'){

                            end1=map[row][left];

                            break;

                    }

                    if(leftskip==1){

                            leftskip--;

                            left--;

                            continue;

                    }

                    end1=map[row][left];

                    break;

            }else{

                    end1=map[row][left];

                    break;

            }

    }

    int rightskip = 1;
    int rightsum_space = 0;
    int rightsum = 0 ;

    while(1){

            if(map[row][right]=='1'){
                    if(rightskip==1){
                        rightsum++;
                    }

                    rightsum_space++;

                    right++;

            }else if(map[row][right]=='*'){

                    if(map[row][right+1]!='1'){

                            end2=map[row][right];

                            break;

                    }

                    if(rightskip==1){

                            rightskip--;

                            right++;

                            continue;

                    }

                    end2=map[row][right];

                    break;

            }else{

                    end2=map[row][right];

                    break;

            }

    }

    *three=forbid_three(leftsum_space,leftsum,rightsum_space,rightsum,end1,end2);
    *four=forbid_four(leftsum_space,leftsum,rightsum_space,rightsum,end1,end2);

}



void forbid_rule_left_right(int row,int colum,int* three , int* four){
        int skip = 1;
        int sum = 1 ;
        int left = colum-1;
        int right = colum +1;
        char end1, end2;

        *three=0;
        *four=0;
        while(1){

                if(map[row][left]=='1'){

                        sum++;

                        left--;

                }else if(map[row][left]=='*'){

                        if(map[row][left-1]=='*'||map[row][left-1]=='#'){

                                end1=map[row][left];

                                break;

                        }

                        if(skip==1){

                                skip--;

                                left--;

                                continue;

                        }

                        end1=map[row][left];

                        break;

                }else{

                        end1=map[row][left];

                        break;

                }

        }

        if(sum==4){

                skip = 1;

        }

        while(1){

                if(map[row][right]=='1'){

                        sum++;

                        right++;

                }else if(map[row][right]=='*'){

                        if(map[row][right+1]=='*'||map[row][right+1]=='#'){

                                end2=map[row][right];

                                break;

                        }

                        if(skip==1){

                                skip--;

                                right++;

                                continue;

                        }

                        end2=map[row][right];

                        break;

                }else{

                        end2=map[row][right];

                        break;

                }

        }

	

        if(sum==3&&end1=='*'&&end2=='*'){

                *three=1;

        }

        if(sum==4&&end1=='*'){

                *four=1;

        }

        if(sum==4&&end2=='*'){

                *four=1;

        }

        if(sum==7){

                *four=2;

        }

}


void forbid_rule_up_down2(int row,int colum,int* three , int* four){

        *three=0;
        *four=0;
        char end1 , end2;

        int upskip = 1;
        int upsum_space = 0;
        int upsum = 0 ;

        int up = row-1;
        int down = row +1;


        while(1){

                if(map[up][colum]=='1'){
                    if(upskip==1){
                        upsum++;
                    }

                    upsum_space++;

                    up--;

                }else if(map[up][colum]=='*'){

                        if(map[up-1][colum]!='1'){

                                end1=map[up][colum];

                                break;

                        }

                        if(upskip==1){

                                upskip--;

                                up--;

                                continue;

                        }

                        end1=map[up][colum];

                        break;

                }else{

                        end1=map[up][colum];

                        break;

                }

        }


        int downskip = 1;
        int downsum_space = 0;
        int downsum = 0 ;


        while(1){

                if(map[down][colum]=='1'){
                        if(downskip==1){
                            downsum++;
                        }
                        downsum_space++;

                        down++;

                }else if(map[down][colum]=='*'){

                        if(map[down+1][colum]!='1'){

                                end2=map[down][colum];

                                break;

                        }

                        if(downskip==1){

                                downskip--;

                                down++;

                                continue;

                        }

                        end2=map[down][colum];

                        break;

                }else{

                        end2=map[down][colum];

                        break;

                }

        }

        *three=forbid_three(upsum_space,upsum,downsum_space,downsum,end1,end2);
        *four=forbid_four(upsum_space,upsum,downsum_space,downsum,end1,end2);

}





void forbid_rule_up_down(int row,int colum,int* three , int* four){
	int skip = 1;
	int sum = 1 ;
	int up = row-1;
	int down = row +1;
	char end1, end2;
	*three=0;
	*four=0;

	while(1){

		if(map[up][colum]=='1'){

			sum++;

			up--;

		}else if(map[up][colum]=='*'){

			if(map[up-1][colum]=='*'||map[up-1][colum]=='#'){

				end1=map[up][colum];

				break;		

			}

			if(skip==1){

				skip--;

				up--;

				continue;

			}

			end1=map[up][colum];

			break;		

		}else{

			end1=map[up][colum];

			break;

		}

	}

	if(sum==4){

		skip = 1;

	}

	while(1){

		if(map[down][colum]=='1'){

			sum++;

			down++;

		}else if(map[down][colum]=='*'){

			if(map[down+1][colum]=='*'||map[down+1][colum]=='#'){

				end2=map[down][colum];

				break;		

			}

			if(skip==1){

				skip--;

				down++;

				continue;

			}

			end2=map[down][colum];

			break;		

		}else{

			end2=map[down][colum];

			break;

		}

	}

	

	if(sum==3&&end1=='*'&&end2=='*'){

		*three=1;

	}

	if(sum==4&&end1=='*'){

		*four=1;

	}

	if(sum==4&&end2=='*'){

		*four=1;

	}

	if(sum==7){

		*four = 2 ;

	}

}

void forbid_rule_leftup_rightdown2(int row,int colum,int* three , int* four){

    *three=0;
    *four=0;
    char end1 , end2;

    int leftupskip = 1;
    int leftupsum_space = 0;
    int leftupsum = 0 ;



    int up = row-1;

    int left = colum -1;



    int down=row+1;

    int right=colum+1;


        while(1){

                if(map[up][left]=='1'){
                    if(leftupskip==1){
                        leftupsum++;
                    }

                        leftupsum_space++;

                        up--;

                        left--;

                }else if(map[up][left]=='*'){

                        if(map[up-1][left-1]!='1'){

                                end1=map[up][left];

                                break;

                        }

                        if(leftupskip==1){

                                leftupskip--;

                                left--;

                                up--;

                                continue;

                        }

                        end1=map[up][colum];

                        break;

                }else{

                        end1=map[up][colum];

                        break;

                }

        }

        int rightdownskip = 1;
        int rightdownsum_space = 0;
        int rightdownsum = 0 ;


        while(1){

                if(map[down][right]=='1'){
                    if(rightdownskip==1){
                        rightdownsum++;
                    }

                        rightdownsum_space++;

                        down++;

                        right++;

                }else if(map[down][right]=='*'){

                        if(map[down+1][right+1]!='1'){

                                end2=map[down][right];

                                break;

                        }

                        if(rightdownskip==1){

                                rightdownskip--;

                                right++;

                                down++;

                                continue;

                        }

                        end2=map[down][right];

                        break;

                }else{

                        end2=map[down][right];

                        break;

                }

        }



        *three=forbid_three(leftupsum_space,leftupsum,rightdownsum_space,rightdownsum,end1,end2);
        *four=forbid_four(leftupsum_space,leftupsum,rightdownsum_space,rightdownsum,end1,end2);

}



void forbid_rule_leftup_rightdown(int row,int colum,int* three , int* four){

	int skip = 1;

	int sum = 1 ;

	int up = row-1;

	int left = colum -1;

	

	int down=row+1;

	int right=colum+1;

	

	char end1, end2;

	*three=0;

	*four=0;

	while(1){

		if(map[up][left]=='1'){

			sum++;

			up--;

			left--;

		}else if(map[up][left]=='*'){

			if(map[up-1][left-1]=='*'||map[up-1][left-1]=='#'){

				end1=map[up][left];

				break;		

			}

			if(skip==1){

				skip--;

				left--;

				up--;

				continue;

			}

			end1=map[up][colum];

			break;		

		}else{

			end1=map[up][colum];

			break;

		}

	}

	if(sum==4){

		skip=1;

	}

	while(1){

		if(map[down][right]=='1'){

			sum++;

			down++;

			right++;

		}else if(map[down][right]=='*'){

                        if(map[down+1][right+1]=='*'||map[down+1][right+1]=='#'){

				end2=map[down][right];

				break;		

			}

                        if(skip==1){

				skip--;

				right++;

				down++;

				continue;

			}

			end2=map[down][right];

			break;		

		}else{

			end2=map[down][right];

			break;

		}

	}

	if(sum==3&&end1=='*'&&end2=='*'){

		*three=1;

	}

	if(sum==4&&end1=='*'){

		*four=1;

	}

	if(sum==4&&end2=='*'){

		*four=1;

	}

	if(sum==7){

		*four=2;

	}

}


void forbid_rule_rightup_leftdown2(int row,int colum,int* three , int* four){
    *three=0;
    *four=0;
    char end1 , end2;
    int rightupskip = 1;
    int rightupsum_space = 0;
    int rightupsum = 0 ;
    int up = row-1;
    int left = colum -1;
    int down=row+1;
    int right=colum+1;


        while(1){

                if(map[up][right]=='1'){
                       if(rightupskip==1){
                            rightupsum++;
                       }

                        rightupsum_space++;

                        up--;

                        right++;

                }else if(map[up][right]=='*'){

                        if(map[up-1][right+1]!='1'){

                                end1=map[up][right];

                                break;

                        }

                        if(rightupskip==1){

                                rightupskip--;

                                up--;

                                right++;

                                continue;

                        }

                        end1=map[up][right];

                        break;

                }else{

                        end1=map[up][right];

                        break;

                }

        }

        int leftdownskip = 1;
        int leftdownsum_space = 0;
        int leftdownsum = 0 ;


        while(1){

                if(map[down][left]=='1'){
                    if(leftdownskip==1){
                        leftdownsum++;
                    }
                    leftdownsum_space++;
                    down++;
                    left--;

                }else if(map[down][left]=='*'){

                        if(map[down+1][left-1]!='1'){

                                end2=map[down][left];

                                break;

                        }

                        if(leftdownskip==1){

                                leftdownskip--;

                                left--;

                                down++;

                                continue;

                        }

                        end2=map[down][left];

                        break;

                }else{

                        end2=map[down][left];

                        break;

                }

        }


    *three=forbid_three(rightupsum_space,rightupsum,leftdownsum_space,leftdownsum,end1,end2);
    *four=forbid_four(rightupsum_space,rightupsum,leftdownsum_space,leftdownsum,end1,end2);
}



void forbid_rule_rightup_leftdown(int row,int colum,int* three , int* four){
	int skip = 1;
	int sum = 1 ;
	int up = row-1;
	int left = colum -1;
	int down=row+1;
	int right=colum+1;
	char end1, end2;
	*three=0;
	*four=0;

	while(1){

		if(map[up][right]=='1'){

			sum++;

			up--;

			right++;

		}else if(map[up][right]=='*'){

			if(map[up-1][right+1]=='*'||map[up-1][right+1]=='#'){

				end1=map[up][right];

				break;		

			}

			if(skip==1){

				skip--;

				up--;

				right++;

				continue;

			}

			end1=map[up][right];

			break;		

		}else{

			end1=map[up][right];

			break;

		}

	}

	if(sum==4){

		skip = 1 ;

	}

	while(1){

		if(map[down][left]=='1'){

			sum++;

			down++;

			left--;

		}else if(map[down][left]=='*'){

			if(map[down+1][left-1]=='*'||map[down+1][left-1]=='#'){

				end2=map[down][left];

				break;		

			}

			if(skip==1){

				skip--;

				left--;

				down++;

				continue;

			}

			end2=map[down][left];

			break;		

		}else{

			end2=map[down][left];

			break;

		}

	}

	

	if(sum==3&&end1=='*'&&end2=='*'){

		*three=1;

	}

	if(sum==4&&end1=='*'){

		*four=1;

	}

	if(sum==4&&end2=='*'){

		*four=1;

	}

	if(sum==7){

		*four=2;

	}

}





int forbid_rule(int row, int colum ){

	int t,f;

	int three = 0 ;

	int four = 0;

    forbid_rule_left_right2(row,colum,&t,&f);
	three=three+t;
	four=four+f;



	forbid_rule_up_down2(row,colum,&t,&f);
	three=three+t;
	four=four+f;

    forbid_rule_leftup_rightdown2(row,colum,&t,&f);
	three=three+t;
	four=four+f;

    forbid_rule_rightup_leftdown2(row,colum,&t,&f);
	three=three+t;
	four=four+f;

	if(three>=2||four>=2){

		return 1;

	}

	return 0;

}





int judgeblack(int row, int colum){
	int left_right = 1 ;
	int up_down = 1 ;
	int leftup_rightdown = 1 ;
	int rightup_leftdown = 1 ;
	int three_forbid = 0 ;
	int four_forbid = 0 ;

	left_right = left_right + sum_left(row,colum,'1') + sum_right(row,colum,'1') ; 	

	up_down = up_down + sum_up(row,colum,'1')+ sum_down(row,colum,'1');

	leftup_rightdown = leftup_rightdown + sum_left_up(row, colum , '1') + sum_right_down(row,colum , '1');		

	rightup_leftdown = rightup_leftdown + sum_right_up(row,colum,'1') + sum_left_down(row,colum,'1');


        if(left_right==5||up_down==5||leftup_rightdown==5||rightup_leftdown==5){

                return 1;

        }

	if(left_right>=6||up_down>=6||leftup_rightdown>=6||rightup_leftdown>=6){

		return 2;

	}

			
	if(forbid_rule(row,colum)){

		return 2;

	}

	return 0;

}





int judge(int row , int colum , char c){

	if(c==BLACK){

		return judgeblack(row,colum);

	}

	if(c==WHITE){

		return judgewhite(row,colum);

	}

}



void game(){
    int turn = 1 ;
    int a , b ;
    int result;
    while(1){
        if(turn==1){
            printf("black turn\n");
        }else{
            printf("whilte turn\n");
        }
        scanf("%d %d",&a,&b);
        if(turn==1){
            PlaceGo(a,b,'1');
            result = judge(a,b,'1');
            turn = 2 ;
        }else{
            PlaceGo(a,b,'2');
            result = judge(a,b,'2');
            turn = 1 ;
        }
        testShow();

        if(result==1){

                printf("black win\n");

                return ;

        }

        if(result==2){

                printf("white win\n");

                return ;

        }

    }
}


int main(int argc, char *argv[]) {
	init();

    game();

	return 0;

}

